package com.kcs.fxmargin.service;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.kcs.common.utils.ConnectionUtils;
import com.kcs.common.utils.Constant;
import com.kcs.fxmargin.dao.MessageDao;
import com.kcs.fxmargin.model.CMessage;

public class MessageService {
	
	MessageDao dao = new MessageDao();

	public List<CMessage> getMessage() throws Exception{
		Connection conn 			= null;
		PreparedStatement pstm 		= null;
		ResultSet rs				= null;
		List<CMessage> messageList 	= new ArrayList<CMessage>();
		
		try{
			conn = ConnectionUtils.getConnection(Constant.MSSQL, Constant.TO); // get connection fxmargin from mssql
			
			messageList = dao.getMessage(conn, pstm, rs);
			
		} catch (Exception e){
			e.printStackTrace();
		} finally {
			if(conn != null ) conn.close();
			if(pstm != null ) pstm.close();
			if(rs   != null ) rs.close();
		}
		
		return messageList;
	}

}
